package com.ocom.webapi.service.impl;

import com.ocom.common.constant.MapKey;
import com.ocom.common.resp.Result;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.AccessClientService;
import com.ocom.webapi.service.CenterConfigService;
import com.ocom.webapi.vo.centerconfig.AddVo;
import com.ocom.webapi.vo.centerconfig.ModifyVo;
import com.ocom.webapi.vo.centerconfig.OnShowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class CenterConfigServiceImpl implements CenterConfigService {

    @Autowired
    private AccessClientService accessClientService;
    /**
     * 中台配置信息列表（CenterConfig/onShow）
     * */
    @Override
    public Result CenterConfigOnShow(OnShowVo onShowVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(), SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_status(),onShowVo.getStatus());
        map.put(mapKey.getKey_regionId(),onShowVo.getRegionId());
        map.put(mapKey.getKey_areaId(),onShowVo.getAreaId());
        map.put(mapKey.getKey_page(),onShowVo.getPage());
        map.put(mapKey.getKey_size(),onShowVo.getSize());
        return accessClientService.GetCenterConfig(map);
    }

    /**
     * 中台配置信息新增（CenterConfig/add）
     * */
    @Override
    public Result CenterConfigAdd(AddVo addVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(),SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_regionId(),addVo.getRegionId());
        map.put(mapKey.getKey_areaId(),addVo.getAreaId());
        map.put(mapKey.getKey_hourTime(),addVo.getHourTime());
        return accessClientService.AddCenterConfig(map);
    }

    /**
     * 修改中台配置信息（updateCenterConfig）【WEB】
     * */
    @Override
    public Result CenterConfigModify(ModifyVo modifyVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(),SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_regionId(),modifyVo.getRegionId());
        map.put(mapKey.getKey_areaId(),modifyVo.getAreaId());
        map.put(mapKey.getKey_hourTime(),modifyVo.getHourTime());
        map.put(mapKey.getKey_id(),modifyVo.getId());
        map.put(mapKey.getKey_status(),modifyVo.getStatus());
        return accessClientService.UpdateCenterConfig(map);
    }

    @Override
    public Result CenterConfigDelete(Long comId, String ids) {
        comId = SecurityUtils.getYoCiUser().getComId();
        return accessClientService.DeleteCenterConfig(comId,ids);
    }
}
